package com.lowca.news.web.controller.common;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lowca.news.web.jsonbean.TreeNodeBean;

@Controller
public class ExampleController {

	@RequestMapping(value = "/example/ajax.do", method = RequestMethod.GET)
	public @ResponseBody
	List<TreeNodeBean> ajax(HttpServletRequest request) {
		List<TreeNodeBean> nodeList = new ArrayList<TreeNodeBean>();
		TreeNodeBean userNode = new TreeNodeBean("user", false, "用户管理", "用户管理",
				"#");
		TreeNodeBean userListNode = new TreeNodeBean("user.list", true, "用户管理",
				"用户列表&gt&gt用户列表", "user/list.do");
		TreeNodeBean userSetRoleNode = new TreeNodeBean("user.setRole", true,
				"权限设置", "用户管理&gt&gt权限设置", "user/set-role.do");
		userNode.getChildren().add(userListNode);
		userNode.getChildren().add(userSetRoleNode);
		TreeNodeBean articleNode = new TreeNodeBean("article", false, "文章管理",
				"文章管理", "#");
		TreeNodeBean articleAddNode = new TreeNodeBean("article.add", true,
				"文章上传", "文章管理&gt&gt文章上传", "article/add.do");
		TreeNodeBean articleListNode = new TreeNodeBean("article.list", true,
				"文章列表", "文章管理&gt&gt文章列表", "article/list.do");
		articleNode.getChildren().add(articleAddNode);
		articleNode.getChildren().add(articleListNode);
		TreeNodeBean commentNode = new TreeNodeBean(" comment", false, "评论管理",
				"评论管理", "#");
		nodeList.add(userNode);
		nodeList.add(articleNode);
		nodeList.add(commentNode);
		return nodeList;
	}

}
